package hbt;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
//import org.hibernate.tool.hbm2ddl.SchemaExport;

public class HibernateFactory
{
    private static final SessionFactory sessionFactory;
    static
    {
        try
        {
        	System.out.println("Entro al SF");
        	 AnnotationConfiguration config = new AnnotationConfiguration();
        	 //config.addAnnotatedClass(dominio.Usuario.class);
        	 config.addAnnotatedClass(repoDAO.ClienteDO.class);
        	 config.addAnnotatedClass(repoDAO.ClaseDO.class);
        	 config.addAnnotatedClass(repoDAO.ProfesorDO.class);
        	 config.addAnnotatedClass(repoDAO.MaquinaDO.class);
        	 config.addAnnotatedClass(repoDAO.EjercicioDO.class);
        	 //config.addAnnotatedClass(dominio.Usuario.class);
        	 //new SchemaExport(config).create(true, true);
             sessionFactory = config.buildSessionFactory();
        }
        catch (Throwable ex)
        {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
  
    public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
}
